﻿using System;
using System.Collections;
using System.Web;
using System.Xml;
using System.Text;
using Whir.Common;
using System.Web.UI;
using Whir.Common.WebHelper;

public partial class Redirect : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string param = NetRequest.GetQueryString("param");
        if (!IsPostBack)
        {
            LoadMenu(param);
        }
    }

    private void LoadMenu(string param)
    {
        //定义Xml操作文档
        XmlDocument menuXd = new XmlDocument();

        try
        {
            //加载XML
            menuXd.Load(Server.MapPath("~/xml/RedirectConfig.xml").ToString());

            //获取根结点
            XmlNode xnFather = menuXd.DocumentElement;

            //获取一级菜单结点
            XmlNodeList firstLevelList = xnFather.ChildNodes;

            //菜单客户端字符串
            StringBuilder firstString = new StringBuilder();

            string key = "", url = "";
            for (int i = 0; i < firstLevelList.Count; i++)
            {
                XmlNode xn = firstLevelList[i];

                key = xn.Attributes["key"].Value;
                url = xn.Attributes["url"].Value;
                if (key.Equals(param))
                {
                    Response.Redirect("~/" + url);
                    break;
                }

                firstString.Append(key);
            }
        }
        catch
        {
            throw new Exception("加载配置文件失败！");
        }
    }
}